package com.xbongbong.paas.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.enums.FlowStatusEnum;
import com.xbongbong.paas.enums.NodeTypeEnum;
import com.xbongbong.paas.enums.ProcessTypeEnum;
import com.xbongbong.paas.enums.TaskTypeEnum;
import com.xbongbong.paas.pojo.ProcessNodeAllReadDTO;
import com.xbongbong.paas.pojo.dto.PaasBatchPrintByProcessDTO;
import com.xbongbong.paas.pojo.dto.ProcessNodeItemDTO;
import com.xbongbong.paas.pojo.dto.ProcessNodeTaskCountDTO;
import com.xbongbong.paas.pojo.dto.ProcessNodeTaskGetDTO;
import com.xbongbong.paas.pojo.dto.ProcessNodeTaskListDTO;
import com.xbongbong.paas.pojo.dto.ProcessNodeTaskReadDTO;
import com.xbongbong.paas.pojo.dto.ProcessNodeTaskUpdateDTO;
import com.xbongbong.paas.pojo.dto.ProcessTaskDelDTO;
import com.xbongbong.paas.pojo.vo.PaasBatchPrintByProcessVO;
import com.xbongbong.paas.pojo.vo.ProcessNodeTaskCountVO;
import com.xbongbong.paas.pojo.vo.ProcessNodeTaskGet4IndexVO;
import com.xbongbong.paas.pojo.vo.ProcessNodeTaskGetVO;
import com.xbongbong.paas.pojo.vo.ProcessNodeTaskListVO;
import com.xbongbong.paas.pojo.vo.ProcessNodeTaskRecordsVO;
import com.xbongbong.paas.pojo.vo.ProcessNodeTaskUpdateVO;
import com.xbongbong.paas.pojo.vo.SummaryDataVO;
import com.xbongbong.paas.redis.PaasRedisHelper;
import com.xbongbong.paas.service.PaasProcessNodeTaskService;
import com.xbongbong.paas.service.UserService;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.thread.TransmittableThreadLocalUtil;
import com.xbongbong.paas.toolbox.wrap.BaseVO;
import com.xbongbong.paas.toolbox.wrap.XbbResponse;
import com.xbongbong.pro.constant.XbbProConstant;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.pro.process.pojo.dto.ProcessUserListDTO;
import com.xbongbong.pro.process.pojo.vo.ProcessUserListVO;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.Objects;

/**
 * Description: 流程列表，操作相关
 *
 * @author 李杰
 * @version v1.0
 * @date 2019/1/18 10:47
 * @since v1.0
 */
@RestController
@RequestMapping(value = XbbProConstant.API_ROOT_PREFIX + "/process/node/task")
public class PaasProcessNodeTaskController {

    @Resource
    private PaasProcessNodeTaskService paasProcessNodeTaskService;
    @Resource
    private PaasRedisHelper paasRedisHelper;
    @Resource
    private UserService userService;

    /**
     * 更新流程任务
     *
     * @param processNodeTaskUpdateDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String update(@RequestBody @Valid ProcessNodeTaskUpdateDTO processNodeTaskUpdateDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskUpdateVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                // 判断是否跳过重复提交校验
                if (!Boolean.TRUE.equals(processNodeTaskUpdateDTO.getIgnoreConCheck())) {
                    //重复提交校验
                    if (!paasRedisHelper.checkConcurrentLock(processNodeTaskUpdateDTO)) {
                        response = new XbbResponse<>(new XbbException(SystemErrorCodeEnum.API_ERROR_100003));
                        return JSON.toJSONString(response);
                    }
                }
                TransmittableThreadLocalUtil.setValue(processNodeTaskUpdateDTO.getSaasMark(), processNodeTaskUpdateDTO.getBusinessType(), processNodeTaskUpdateDTO.getMenuId(), processNodeTaskUpdateDTO.getDistributorMark());
                ProcessNodeTaskUpdateVO processNodeTaskUpdateVO = paasProcessNodeTaskService.update(processNodeTaskUpdateDTO);
                response = new XbbResponse<>(processNodeTaskUpdateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 全部流程任务
     *
     * @param processNodeTaskListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String list(@RequestBody @Valid ProcessNodeTaskListDTO processNodeTaskListDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                processNodeTaskListDTO.setProcessType(ProcessTypeEnum.ALL.getValue());
                ProcessNodeTaskListVO processTaskUpdateVO = paasProcessNodeTaskService.allList(processNodeTaskListDTO);
                response = new XbbResponse<>(processTaskUpdateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 我提交的流程
     *
     * @param processNodeTaskListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/createList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String createList(@RequestBody @Valid ProcessNodeTaskListDTO processNodeTaskListDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                processNodeTaskListDTO.setProcessType(ProcessTypeEnum.CREATE.getValue());
                processNodeTaskListDTO.setCreatorId(processNodeTaskListDTO.getUserId());
                processNodeTaskListDTO.setNodeType(NodeTypeEnum.START_PROCESS_NODE.getNodeType());
                ProcessNodeTaskListVO processTaskUpdateVO = paasProcessNodeTaskService.createList(processNodeTaskListDTO);
                response = new XbbResponse<>(processTaskUpdateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 提交给我的流程
     *
     * @param processNodeTaskListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/todoList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String todoList(@RequestBody @Valid ProcessNodeTaskListDTO processNodeTaskListDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                processNodeTaskListDTO.setProcessType(ProcessTypeEnum.TODO.getValue());
                processNodeTaskListDTO.setNodeType(NodeTypeEnum.PROCESS_NODE.getNodeType());
                ProcessNodeTaskListVO processTaskUpdateVO = paasProcessNodeTaskService.todoList(processNodeTaskListDTO);
                response = new XbbResponse<>(processTaskUpdateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 抄送给我的流程
     *
     * @param processNodeTaskListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/ccList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String ccList(@RequestBody @Valid ProcessNodeTaskListDTO processNodeTaskListDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                processNodeTaskListDTO.setProcessType(ProcessTypeEnum.CC.getValue());
                processNodeTaskListDTO.setTaskType(TaskTypeEnum.CC.getType());
                ProcessNodeTaskListVO processTaskUpdateVO = paasProcessNodeTaskService.ccList(processNodeTaskListDTO);
                response = new XbbResponse<>(processTaskUpdateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 流程详情，包含流程权限操作,以及表单数据
     *
     * @param processNodeTaskGetDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/detail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String detail(@RequestBody @Valid ProcessNodeTaskGetDTO processNodeTaskGetDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskGetVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(processNodeTaskGetDTO.getSaasMark(), processNodeTaskGetDTO.getBusinessType(), processNodeTaskGetDTO.getMenuId(), processNodeTaskGetDTO.getDistributorMark());
                ProcessNodeTaskGetVO processNodeTaskGetVO = paasProcessNodeTaskService.detail(processNodeTaskGetDTO);
                response = new XbbResponse<>(processNodeTaskGetVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 人员的返回列表
     *
     * @param processUserListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/userList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String userList(@RequestBody @Valid ProcessUserListDTO processUserListDTO, BindingResult br) {
        XbbResponse<ProcessUserListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                ProcessUserListVO processUserListVO = userService.getProcessUserList(processUserListDTO);
                response = new XbbResponse<>(processUserListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 审批记录和抄送人列表
     *
     * @param processNodeTaskGetDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/records", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String records(@RequestBody @Valid ProcessNodeTaskGetDTO processNodeTaskGetDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskRecordsVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                ProcessNodeTaskRecordsVO processNodeTaskRecordsVO = paasProcessNodeTaskService.records(processNodeTaskGetDTO);
                response = new XbbResponse<>(processNodeTaskRecordsVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 首页我提交的流程
     *
     * @param processNodeTaskListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/index/createList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String createListForIndex(@RequestBody @Valid ProcessNodeTaskListDTO processNodeTaskListDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                processNodeTaskListDTO.setProcessType(ProcessTypeEnum.CREATE.getValue());
                processNodeTaskListDTO.setCreatorId(processNodeTaskListDTO.getUserId());
                processNodeTaskListDTO.setNodeType(NodeTypeEnum.START_PROCESS_NODE.getNodeType());
                processNodeTaskListDTO.setFlowStatusIn(Arrays.asList(FlowStatusEnum.IN_APPROVAL.getType(), FlowStatusEnum.APPROVAL_PENDING.getType()));
                if (null == processNodeTaskListDTO.getPageSize()){
                    processNodeTaskListDTO.setPageSize(PaasConstant.APPROVAL_INDEX_SIZE);
                }
                ProcessNodeTaskListVO processTaskUpdateVO = paasProcessNodeTaskService.createList(processNodeTaskListDTO);
                response = new XbbResponse<>(processTaskUpdateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 首页提交给我的流程
     *
     * @param processNodeTaskListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/index/todoList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String todoListForIndex(@RequestBody @Valid ProcessNodeTaskListDTO processNodeTaskListDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                processNodeTaskListDTO.setProcessType(ProcessTypeEnum.TODO.getValue());
                processNodeTaskListDTO.setNodeType(NodeTypeEnum.PROCESS_NODE.getNodeType());
                processNodeTaskListDTO.setTaskType(TaskTypeEnum.UNTREATED.getType());
                if (null == processNodeTaskListDTO.getPageSize()){
                    processNodeTaskListDTO.setPageSize(PaasConstant.APPROVAL_INDEX_SIZE);
                }
                ProcessNodeTaskListVO processTaskUpdateVO = paasProcessNodeTaskService.todoList(processNodeTaskListDTO);
                response = new XbbResponse<>(processTaskUpdateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取流程列表中单个节点的摘要信息
     *
     * @param processNodeItemDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/summaryItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String summaryItem(@RequestBody @Valid ProcessNodeItemDTO processNodeItemDTO, BindingResult br) {
        XbbResponse<SummaryDataVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                SummaryDataVO summaryDataVO = paasProcessNodeTaskService.summaryItem(processNodeItemDTO);
                response = new XbbResponse<>(summaryDataVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    @RequestMapping(value = "/count", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String count(@RequestBody @Valid ProcessNodeTaskCountDTO processNodeTaskCountDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskCountVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                ProcessNodeTaskCountVO processNodeTaskCountVO = paasProcessNodeTaskService.count(processNodeTaskCountDTO);
                response = new XbbResponse<>(processNodeTaskCountVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    @RequestMapping(value = "/readNode", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String readNode(@RequestBody @Valid ProcessNodeTaskReadDTO processNodeTaskReadDTO, BindingResult br) {
        XbbResponse<BaseVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                BaseVO baseVO = paasProcessNodeTaskService.readNode(processNodeTaskReadDTO);
                response = new XbbResponse<>(baseVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    @RequestMapping(value = "/delTask", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String delTask(@RequestBody @Valid ProcessTaskDelDTO processTaskDelDTO, BindingResult br) {
        XbbResponse<BaseVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                BaseVO baseVO = paasProcessNodeTaskService.delTask(processTaskDelDTO);
                response = new XbbResponse<>(baseVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 管理员转交
     *
     * @param processNodeTaskUpdateDTO
     * @param br
     * @throws
     * @return
     * @author hongxiao
     * @date 2019-11-05 16:19
     * @since
     * @version
     */
    @RequestMapping(value = "/adminTransfer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String adminTransfer(@RequestBody @Valid ProcessNodeTaskUpdateDTO processNodeTaskUpdateDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskUpdateVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            // 判断是否跳过重复提交校验
            if (!Boolean.TRUE.equals(processNodeTaskUpdateDTO.getIgnoreConCheck())) {
                //重复提交校验
                if (!paasRedisHelper.checkConcurrentLock(processNodeTaskUpdateDTO)) {
                    response = new XbbResponse<>(new XbbException(SystemErrorCodeEnum.API_ERROR_100003));
                    return JSON.toJSONString(response);
                }
            }
            try {
                TransmittableThreadLocalUtil.setValue(processNodeTaskUpdateDTO.getSaasMark(), processNodeTaskUpdateDTO.getBusinessType(), processNodeTaskUpdateDTO.getMenuId(), processNodeTaskUpdateDTO.getDistributorMark());
                ProcessNodeTaskUpdateVO processNodeTaskUpdateVO = paasProcessNodeTaskService.adminTransfer(processNodeTaskUpdateDTO);
                response = new XbbResponse<>(processNodeTaskUpdateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取审批批量打印
     *
     * @param paasBatchPrintByProcessDTO
     * @param br
     * @throws
     * @return
     * @author: hongxiao
     * @date: 2020-02-07 15:29
     * @since: v4.13.0
     * @version: v4.13.0
     */
    @RequestMapping(value = "/getBatchPrintByProcess", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getBatchPrintByProcess(@RequestBody @Valid PaasBatchPrintByProcessDTO paasBatchPrintByProcessDTO, BindingResult br) {
        XbbResponse<PaasBatchPrintByProcessVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try{
                PaasBatchPrintByProcessVO paasBatchPrintByProcessVO = paasProcessNodeTaskService.getBatchPrintByProcess(paasBatchPrintByProcessDTO);
                response = new XbbResponse<>(paasBatchPrintByProcessVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 审批抄送消息一键已读
     * @param processNodeAllReadDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/readAllCcList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String readAllCcList(@RequestBody @Valid ProcessNodeAllReadDTO processNodeAllReadDTO, BindingResult br) {
        XbbResponse<BaseVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                BaseVO baseVO = paasProcessNodeTaskService.readAllCcList(processNodeAllReadDTO);
                response = new XbbResponse<>(baseVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }
    /**
     * 首页审批详情
     * @param processNodeTaskGetDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/index/detail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String readAllCcList(@RequestBody @Valid ProcessNodeTaskGetDTO processNodeTaskGetDTO, BindingResult br) {
        XbbResponse<ProcessNodeTaskGet4IndexVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                ProcessNodeTaskGet4IndexVO processNodeTaskGet4IndexVO = paasProcessNodeTaskService.detail4Index(processNodeTaskGetDTO);
                response = new XbbResponse<>(processNodeTaskGet4IndexVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }
}
